Just a thought: It would be an interesting experiment to count the memory 
usage in the C++ version of the benchmark to match Java's memory 
consumption (1.5-2.5 GB) and to deallocate only those C++ objects which 
increase memory consumption beyond this limit. At the end of the benchmark, 
C++ could just leave the 1.5-2.5 GB of object-bytes on the heap, without 
ever deallocating them in C++, and return from the main() function to take 
advantage of the fact that the memory will be deallocated by the operating 
system when the benchmark process terminates.

In a radical version of this idea, all calls to free() and delete that do 
not have side-effects and do not cause data cache trashing could in any C++ 
application be no-ops (empty operations) until memory consumption reaches 1 
GB. Memory allocation until 1 GB is reached is of course just an ADD 
instruction, because that memory will never be reused for other objects.

Maybe this strategy is a part of how Java is able to outperform C++.

On Thursday, February 13, 2020 at 6:33:55 PM UTC+1, Robert Engels wrote:
>
> I won't dispute that, but at least this particular case, it requires 
> on-going maintenance by the developer (company). In this case of Java very 
> few performance improvements have required code changes.
>
> Using a different structure entirely (hash map vs. tree map) is a 
> different issue - it touches on the robustness of the stdlib, dynamic 
> runtime class replacement, etc. I can only assume that std::map was used 
> because it made the code easier/portable to write in C++ rather than adding 
> an outside dependency or custom hash map. implementation (In the Java code, 
> they use a custom IntegerSet, IntegerList to avoid boxing...)
>
> -----Original Message----- 
> From: ⚛ <0xe2.0...@gmail.com <javascript:>> 
> Sent: Feb 13, 2020 9:57 AM 
> To: golang-nuts 
> Subject: Re: [go-nuts] Go without garbage collector 
>
> On Thursday, February 13, 2020 at 3:05:45 PM UTC+1, Robert Engels wrote:
>>
>> The code hasn’t been changed. The performance numbers have changed 
>> dramatically with no developer intervention. No “hand optimizing” required.
>>
>
> C++ evolves over time also. Hashmaps have been added to C++ in C++11, 
> which from today's viewpoint invalidates most benchmarks published before 
> year 2011 that translated Java's HashMap to C++'s std::map.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golan...@googlegroups.com <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/f5a4a3cf-e4ce-4fb4-af03-fa5f32a5ce62%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/f5a4a3cf-e4ce-4fb4-af03-fa5f32a5ce62%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/33723531-2ad2-4161-ae3e-14ec375cbb90%40googlegroups.com.

Reply via email to