You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@datasketches.apache.org by "proost (via GitHub)" <gi...@apache.org> on 2026/09/05 06:05:30 UTC

[PR] perf: use value type instead of pointer [datasketches-go]

proost opened a new pull request, #177:
URL: https://github.com/apache/datasketches-go/pull/177

   Current "GetFrequentItems" returned slice of pointers. It makes large heap allocations and finally this lead to huge GC overhead. 
   
   I propose use value type instead.
   
   Here is benchmark:
   
   ```
   goos: darwin
   goarch: arm64
   pkg: github.com/apache/datasketches-go/frequencies
   cpu: Apple M4 Pro
   BenchmarkSortItems_Row_Pointer
   BenchmarkSortItems_Row_Pointer/size=10
   BenchmarkSortItems_Row_Pointer/size=10-12         	 4225843	       276.6 ns/op	     568 B/op	      15 allocs/op
   BenchmarkSortItems_Row_Pointer/size=100
   BenchmarkSortItems_Row_Pointer/size=100-12        	  370392	      2956 ns/op	    5368 B/op	     108 allocs/op
   BenchmarkSortItems_Row_Pointer/size=1000
   BenchmarkSortItems_Row_Pointer/size=1000-12       	   34378	     33689 ns/op	   49528 B/op	    1011 allocs/op
   BenchmarkSortItems_Row_Pointer/size=10000
   BenchmarkSortItems_Row_Pointer/size=10000-12      	    2156	    518306 ns/op	  630392 B/op	   10018 allocs/op
   PASS
   
   
   goos: darwin
   goarch: arm64
   pkg: github.com/apache/datasketches-go/frequencies
   cpu: Apple M4 Pro
   BenchmarkSortItems_Row_Value
   BenchmarkSortItems_Row_Value/size=10
   BenchmarkSortItems_Row_Value/size=10-12         	 8494632	       124.3 ns/op	     320 B/op	       1 allocs/op
   BenchmarkSortItems_Row_Value/size=100
   BenchmarkSortItems_Row_Value/size=100-12        	  574056	      1867 ns/op	    3200 B/op	       1 allocs/op
   BenchmarkSortItems_Row_Value/size=1000
   BenchmarkSortItems_Row_Value/size=1000-12       	   56760	     20631 ns/op	   32768 B/op	       1 allocs/op
   BenchmarkSortItems_Row_Value/size=10000
   BenchmarkSortItems_Row_Value/size=10000-12      	    2941	    355211 ns/op	  327680 B/op	       1 allocs/op
   PASS
   
   goos: darwin
   goarch: arm64
   pkg: github.com/apache/datasketches-go/frequencies
   cpu: Apple M4 Pro
   BenchmarkSortItems_RowItem_Pointer
   BenchmarkSortItems_RowItem_Pointer/size=10
   BenchmarkSortItems_RowItem_Pointer/size=10-12         	 3026780	       390.7 ns/op	     728 B/op	      15 allocs/op
   BenchmarkSortItems_RowItem_Pointer/size=100
   BenchmarkSortItems_RowItem_Pointer/size=100-12        	  268033	      4498 ns/op	    6968 B/op	     108 allocs/op
   BenchmarkSortItems_RowItem_Pointer/size=1000
   BenchmarkSortItems_RowItem_Pointer/size=1000-12       	   23358	     50842 ns/op	   65528 B/op	    1011 allocs/op
   BenchmarkSortItems_RowItem_Pointer/size=10000
   BenchmarkSortItems_RowItem_Pointer/size=10000-12      	    1527	    758682 ns/op	  790403 B/op	   10018 allocs/op
   PASS
   
   goos: darwin
   goarch: arm64
   pkg: github.com/apache/datasketches-go/frequencies
   cpu: Apple M4 Pro
   BenchmarkSortItems_RowItem_Value
   BenchmarkSortItems_RowItem_Value/size=10
   BenchmarkSortItems_RowItem_Value/size=10-12         	 4171860	       274.2 ns/op	     416 B/op	       1 allocs/op
   BenchmarkSortItems_RowItem_Value/size=100
   BenchmarkSortItems_RowItem_Value/size=100-12        	  326707	      3848 ns/op	    4096 B/op	       1 allocs/op
   BenchmarkSortItems_RowItem_Value/size=1000
   BenchmarkSortItems_RowItem_Value/size=1000-12       	   27349	     43786 ns/op	   40960 B/op	       1 allocs/op
   BenchmarkSortItems_RowItem_Value/size=10000
   BenchmarkSortItems_RowItem_Value/size=10000-12      	    1557	    719896 ns/op	  401409 B/op	       1 allocs/op
   PASS
   ```
   
   Problem is this is BREAKING CHANGE. But acceptable. 
   
   1. this project is under development.
   2. Users can't aware changes. Because usually use with "for" loop. So it doesn't change any for loop logic. And all fields is private. Either pointer type or value type, user can access using Getter only.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org


Re: [PR] perf: use value type instead of pointer [datasketches-go]

Posted by "proost (via GitHub)" <gi...@apache.org>.
proost merged PR #177:
URL: https://github.com/apache/datasketches-go/pull/177


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org


Re: [PR] perf: use value type instead of pointer [datasketches-go]

Posted by "proost (via GitHub)" <gi...@apache.org>.
proost commented on PR #177:
URL: https://github.com/apache/datasketches-go/pull/177#issuecomment-5644151313

   @freakyzoidberg 
   Can you review this? This PR accompany breaking changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org