Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float precision difference in arm64 vs x86_64 #1727

Open
sanikolaev opened this issue Jan 15, 2024 · 3 comments
Open

Float precision difference in arm64 vs x86_64 #1727

sanikolaev opened this issue Jan 15, 2024 · 3 comments
Assignees

Comments

@sanikolaev
Copy link
Collaborator

Tests are not passed on Mac ARM (perhaps not only on Mac) likely because of a rounding issue.

@sanikolaev
Copy link
Collaborator Author

MRE

Not sure it's the only issue though:

x86_64 (dev2):

mysql> DROP TABLE IF EXISTS test; CREATE TABLE test (flt float); INSERT INTO test (id, flt) VALUES ( 1, 1.1); select flt*flt+flt from test;
--------------
DROP TABLE IF EXISTS test
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
CREATE TABLE test (flt float)
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
INSERT INTO test (id, flt) VALUES ( 1, 1.1)
--------------

Query OK, 1 row affected (0.00 sec)

--------------
select flt*flt+flt from test
--------------

+-------------+
| flt*flt+flt |
+-------------+
|    2.310000 |
+-------------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

arm64 (Sergey's mac):

mysql> DROP TABLE IF EXISTS test; CREATE TABLE test (flt float); INSERT INTO test (id, flt) VALUES ( 1, 1.1); select flt*flt+flt from test;
--------------
DROP TABLE IF EXISTS test
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
CREATE TABLE test (flt float)
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
INSERT INTO test (id, flt) VALUES ( 1, 1.1)
--------------

Query OK, 1 row affected (0.00 sec)

--------------
select flt*flt+flt from test
--------------

+-------------+
| flt*flt+flt |
+-------------+
|  2.31000018 |
+-------------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---

Expected: same float values returned in both cases.

@sanikolaev
Copy link
Collaborator Author

Note, the following query returns the same value on arm64 and x86_64:

mysql> select 1.1*1.1+1.1;
--------------
select 1.1*1.1+1.1
--------------

+-------------+
| 1.1*1.1+1.1 |
+-------------+
|    2.310000 |
+-------------+
1 row in set (0.04 sec)

@sanikolaev sanikolaev changed the title Rounding issue in ubertest.php Float precision difference in arm64 vs x86_64 Jan 15, 2024
@klirichek
Copy link
Contributor

Just a test summary, fyi


testing test_125, select expressions, functions, operators... done; 1/1 subtests FAILED:

=== query 20 diff start ===
--- reference	2024-03-20 16:42:22.726459956 +0700
+++ current	2024-03-20 16:42:22.726363332 +0700
@@ -1,5 +1,5 @@
 sphinxql-20> SELECT GEODIST(0,0,1,1) FROM test WHERE id=10;
 	geodist(0,0,1,1)
-	8120146.500000
+	8120145.500000
 1 rows in set

=== query 20 diff end ===
=== query 100 diff start ===
--- reference	2024-03-20 16:42:22.760943418 +0700
+++ current	2024-03-20 16:42:22.760874877 +0700
@@ -1,5 +1,5 @@
 sphinxql-100> SELECT GEODIST(0,0,1,1,{in=radians,out=kilometers}) FROM test WHERE id=10;
 	geodist(0,0,1,1,{in=radians,out=kilometers})
-	8120.146973
+	8120.145996
 1 rows in set

=== query 100 diff end ===
=== query 123 diff start ===
--- reference	2024-03-20 16:42:22.765018129 +0700
+++ current	2024-03-20 16:42:22.764958963 +0700
@@ -1,8 +1,8 @@
 sphinxql-123> select GEODIST(0,0,1,1, {in=radians, out=m} ) FROM dist;
 	geodist(0,0,1,1, {in=radians, out=m} )
-	8120146.500000
-	8120146.500000
-	8120146.500000
-	8120146.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
 4 rows in set

=== query 123 diff end ===
=== query 124 diff start ===
--- reference	2024-03-20 16:42:22.768800968 +0700
+++ current	2024-03-20 16:42:22.768735385 +0700
@@ -1,8 +1,8 @@
 sphinxql-124> select GEODIST(0,0,1,1, {out=m, in=radians} ) FROM dist;
 	geodist(0,0,1,1, {out=m, in=radians} )
-	8120146.500000
-	8120146.500000
-	8120146.500000
-	8120146.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
 4 rows in set

=== query 124 diff end ===
=== query 125 diff start ===
--- reference	2024-03-20 16:42:22.772421683 +0700
+++ current	2024-03-20 16:42:22.772362392 +0700
@@ -1,8 +1,8 @@
 sphinxql-125> select GEODIST(0,0,1,1, {out=m} ) FROM dist;
 	geodist(0,0,1,1, {out=m} )
-	8120146.500000
-	8120146.500000
-	8120146.500000
-	8120146.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
 4 rows in set

=== query 125 diff end ===
=== query 126 diff start ===
--- reference	2024-03-20 16:42:22.776118565 +0700
+++ current	2024-03-20 16:42:22.776058107 +0700
@@ -1,8 +1,8 @@
 sphinxql-126> select GEODIST(0,0,1,1, {in=radians} ) FROM dist;
 	geodist(0,0,1,1, {in=radians} )
-	8120146.500000
-	8120146.500000
-	8120146.500000
-	8120146.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
+	8120145.500000
 4 rows in set

=== query 126 diff end ===

testing test_144, query vs stack overflow... done; 1/1 subtests FAILED:

=== query 1 diff start ===
--- reference	2024-03-20 16:43:22.055549572 +0700
+++ current	2024-03-20 16:43:22.055456073 +0700
@@ -6,17 +6,17 @@
   4 => 'snippets fast-path ext query stack overflow',
   5 =>
   array (
-    'snippet' => '<b>fast</b> path <b>word word1000</b>',
+    'snippet' => 'fast path word word1000',
   ),
   6 => 'snippets ext query stack overflow',
   7 =>
   array (
-    'snippet' => ' ...  a <b>fast</b> path is going here <b>word word1000</b> ... ',
+    'snippet' => 'not a fast path is going here word  ... ',
   ),
   8 => 'INSERT INTO test VALUES (2, \'fast path word word1000\', 1 )',
   9 => 'total affected 1',
   10 => 'SELECT * FROM test WHERE MATCH(\'fast  | ( word word1 ) | ( word word2 )... skipped on citate
-  11 => 'total found 1',
+  11 => 'error 1064 : table test: query too complex, not enough stack (thread_stack=595K or higher required)',
   12 => 'SELECT * FROM test WHERE idd = 94054 OR idd = 871857 OR idd = 767031 OR idd = 299363 OR idd = 49... skipped on cite
   13 => 'error 1064',
 )
=== query 1 diff end ===

testing test_163, string attribute vs different indexes, attributes UNION... done; 1/1 subtests FAILED:
(this test fails ONLY on macos)


=== query 72 diff start ===
--- reference	2024-03-20 16:43:45.039851929 +0700
+++ current	2024-03-20 16:43:45.039762680 +0700
@@ -1,5 +1,5 @@
 sphinxql-72> select *, 123456, 2+2, sin(1.0), sin(idd), idd+1, count(*) from count2;
 	id	text	idd	123456	2+2	sin(1.0)	sin(idd)	idd+1	count(*)
-	10	of the fox	22	123456	4	0.84147096	-0.00885131	23	2
+	10	of the fox	22	123456	4	0.841471	-0.00885131	23	2
 1 rows in set

=== query 72 diff end ===
=== query 73 diff start ===
--- reference	2024-03-20 16:43:45.044403094 +0700
+++ current	2024-03-20 16:43:45.044338136 +0700
@@ -1,5 +1,5 @@
 sphinxql-73> select *, 123456, 2+2, sin(1.0), sin(idd), idd+1, count(*) from count2 where id in (1,2);
 	id	text	idd	123456	2+2	sin(1.0)	sin(idd)	idd+1	count(*)
-	NULL	NULL	NULL	123456	4	0.84147096	NULL	NULL	0
+	NULL	NULL	NULL	123456	4	0.841471	NULL	NULL	0
 1 rows in set

=== query 73 diff end ===

testing test_184, expression based ranker... done; 1/1 subtests FAILED:

=== query 37 diff start ===
--- reference	2024-03-20 16:44:30.131755233 +0700
+++ current	2024-03-20 16:44:30.131672400 +0700
@@ -1,5 +1,5 @@
 sphinxql-37> select *, packedfactors() from dup where match(' that | was | that ') ORDER by id ASC option ranker=expr('1'),  idf='plain,tfidf_unnormalized';
 	id	f1	f2	idd	f1_len	f2_len	packedfactors()
-	3	If there were a schmillion hours in the day, maybe I d have enough time.	Puerto Rico was fun 910 s of the time.  I ve been told time and time again that I need to wait and see how things play out, that it needs time.  It s not that simple, I m not a patient person in the least, and I feel like I don t have time to devote to all this shit.  I haven y begun any school work yet, anf now I m sick.  I can t begin to describe how alone I feel, how miserably alone.  Not just because I m home from PR and there s nobody around, but for so many other reasons I don t want to get into, and that s why this entry along with every other one ever written will remain vague.  Everything is a reminder.  While in I was down there I did something I haven t done for a long time.  I talked to God.  I mean I pray, but this was a conversation, just two people talking about everything that concerns me.  It was awesome.  I ve never had a strong relationship with my father,so I like it that God fills that role.  However I have realized I don t really have a very strong relationship with Jesus, I do with God, and I know they re all connected but, I never really pray to Jesus or talk to him.  I need to work on that, along with a crap load of other stiff. With All Due Respect, Corey Paul Florindi I	11	15	253	bm25=1205, bm25a=1.01441383, field_mask=2, doc_word_count=2, field1=(lcs=1, hit_count=12, word_count=2, tf_idf=5.168118, min_idf=0.43067655, max_idf=0.43067655, sum_idf=0.86135310, min_hit_pos=3, min_best_span_pos=3, exact_hit=0, max_window_hits=1, min_gaps=3, exact_order=1, lccs=1, wlccs=0.43067655, atc=0.25648326), word0=(tf=8, idf=0.43067655), word1=(tf=4, idf=0.43067655)
+	3	If there were a schmillion hours in the day, maybe I d have enough time.	Puerto Rico was fun 910 s of the time.  I ve been told time and time again that I need to wait and see how things play out, that it needs time.  It s not that simple, I m not a patient person in the least, and I feel like I don t have time to devote to all this shit.  I haven y begun any school work yet, anf now I m sick.  I can t begin to describe how alone I feel, how miserably alone.  Not just because I m home from PR and there s nobody around, but for so many other reasons I don t want to get into, and that s why this entry along with every other one ever written will remain vague.  Everything is a reminder.  While in I was down there I did something I haven t done for a long time.  I talked to God.  I mean I pray, but this was a conversation, just two people talking about everything that concerns me.  It was awesome.  I ve never had a strong relationship with my father,so I like it that God fills that role.  However I have realized I don t really have a very strong relationship with Jesus, I do with God, and I know they re all connected but, I never really pray to Jesus or talk to him.  I need to work on that, along with a crap load of other stiff. With All Due Respect, Corey Paul Florindi I	11	15	253	bm25=1205, bm25a=1.014414, field_mask=2, doc_word_count=2, field1=(lcs=1, hit_count=12, word_count=2, tf_idf=5.168118, min_idf=0.43067655, max_idf=0.43067655, sum_idf=0.86135310, min_hit_pos=3, min_best_span_pos=3, exact_hit=0, max_window_hits=1, min_gaps=3, exact_order=1, lccs=1, wlccs=0.43067655, atc=0.25648326), word0=(tf=8, idf=0.43067655), word1=(tf=4, idf=0.43067655)
 1 rows in set

- bm25a=1.01441383
+ bm25a=1.014414
=== query 37 diff end ===

testing test_205, idf=plain vs distributed... done; 1/1 subtests FAILED:

=== query 8 diff start ===
--- reference	2024-03-20 16:45:10.968966878 +0700
+++ current	2024-03-20 16:45:10.968901462 +0700
@@ -1,5 +1,5 @@
 sphinxql-8> select *, weight() as w, packedfactors() as p from kw where match('t* starts h*') option ranker=expr('sum(lcs)*1000+bm25'), debug_no_payload=1, idf=tfidf_unnormalized;
 	id	text	gid	w	p
-	1	test starts here	11	3996	bm25=996, bm25a=1.42170060, field_mask=1, doc_word_count=3, field0=(lcs=3, hit_count=3, word_count=3, tf_idf=1.19821072, min_idf=0.36389026, max_idf=0.44912219, sum_idf=1.19821072, min_hit_pos=1, min_best_span_pos=1, exact_hit=1, max_window_hits=1, min_gaps=0, exact_order=1, lccs=3, wlccs=1.19821072, atc=0.56315815), word0=(tf=1, idf=0.38519824), word1=(tf=1, idf=0.44912219), word2=(tf=1, idf=0.36389026)
+	1	test starts here	11	3996	bm25=996, bm25a=1.42170048, field_mask=1, doc_word_count=3, field0=(lcs=3, hit_count=3, word_count=3, tf_idf=1.19821072, min_idf=0.36389026, max_idf=0.44912219, sum_idf=1.19821072, min_hit_pos=1, min_best_span_pos=1, exact_hit=1, max_window_hits=1, min_gaps=0, exact_order=1, lccs=3, wlccs=1.19821072, atc=0.56315815), word0=(tf=1, idf=0.38519824), word1=(tf=1, idf=0.44912219), word2=(tf=1, idf=0.36389026)
 1 rows in set

=== query 8 diff end ===
=== query 10 diff start ===
--- reference	2024-03-20 16:45:10.973404960 +0700
+++ current	2024-03-20 16:45:10.973351002 +0700
@@ -1,6 +1,6 @@
 sphinxql-10> select *, weight() as w, packedfactors() as p from kw where match('t* ( starts | from ) h*') option ranker=expr('sum(lcs)*1000+bm25'), debug_no_payload=1, idf=tfidf_unnormalized;
 	id	text	gid	w	p
-	1	test starts here	11	2996	bm25=996, bm25a=1.42170060, field_mask=1, doc_word_count=3, field0=(lcs=2, hit_count=3, word_count=3, tf_idf=1.19821072, min_idf=0.36389026, max_idf=0.44912219, sum_idf=1.19821072, min_hit_pos=1, min_best_span_pos=1, exact_hit=0, max_window_hits=1, min_gaps=0, exact_order=0, lccs=2, wlccs=0.83432043, atc=0.56315815), word0=(tf=1, idf=0.38519824), word1=(tf=1, idf=0.44912219), word2=(tf=0, idf=0.000000), word3=(tf=1, idf=0.36389026)
+	1	test starts here	11	2996	bm25=996, bm25a=1.42170048, field_mask=1, doc_word_count=3, field0=(lcs=2, hit_count=3, word_count=3, tf_idf=1.19821072, min_idf=0.36389026, max_idf=0.44912219, sum_idf=1.19821072, min_hit_pos=1, min_best_span_pos=1, exact_hit=0, max_window_hits=1, min_gaps=0, exact_order=0, lccs=2, wlccs=0.83432043, atc=0.56315815), word0=(tf=1, idf=0.38519824), word1=(tf=1, idf=0.44912219), word2=(tf=0, idf=0.000000), word3=(tf=1, idf=0.36389026)
 	2	the text from hox	11	2996	bm25=996, bm25a=1.11487055, field_mask=1, doc_word_count=3, field0=(lcs=2, hit_count=4, word_count=3, tf_idf=1.13428676, min_idf=0.000000, max_idf=0.38519824, sum_idf=0.74908853, min_hit_pos=1, min_best_span_pos=3, exact_hit=1, max_window_hits=1, min_gaps=0, exact_order=0, lccs=2, wlccs=0.36389026, atc=0.16384478), word0=(tf=2, idf=0.38519824), word1=(tf=0, idf=0.44912219), word2=(tf=1, idf=0.000000), word3=(tf=1, idf=0.36389026)
 2 rows in set

=== query 10 diff end ===


testing test_253, expressions, hashes, query cache... done; 1/1 subtests FAILED:

=== query 39 diff start ===
--- reference	2024-03-20 16:46:13.754853987 +0700
+++ current	2024-03-20 16:46:13.754771280 +0700
@@ -1,7 +1,7 @@
 sphinxql-39> select flt a1, flt a2, flt a3, madd(a1,a2,a3) b, mul3(a1,a2,a3) c, b+c d from test where match('title') and d>0;
 	a1	a2	a3	b	c	d
-	1.100000	1.100000	1.100000	2.310000	1.33100009	3.641000
-	2.200000	2.200000	2.200000	7.040000	10.648001	17.688000
+	1.100000	1.100000	1.100000	2.31000018	1.33100009	3.64100027
+	2.200000	2.200000	2.200000	7.04000044	10.648001	17.688002
 	3.300000	3.300000	3.300000	14.190000	35.936996	50.126995
 	4.400000	4.400000	4.400000	23.760000	85.184006	108.944008
 	5.500000	5.500000	5.500000	35.750000	166.375000	202.125000
=== query 39 diff end ===
=== query 49 diff start ===
--- reference	2024-03-20 16:46:13.759345111 +0700
+++ current	2024-03-20 16:46:13.759276820 +0700
@@ -2,7 +2,7 @@
sphinxql-49> select flt x, flt y, geodist(x,y,0.0,0.0) a, geodist(x,y,x+1.0,y+1.0) b, geodist(x-1.0,y-1.0,x+1.0,y+1.0) c, a+b+c d from test where match('title') and d>0;
 	x	y	a	b	c	d
 	1.100000	1.100000	8687231.000000	5536523.500000	8098289.500000	22322044.000000
 	2.200000	2.200000	7754367.500000	8264162.500000	9394177.000000	25412708.000000
-	3.300000	3.300000	1424404.125000	7672437.500000	15855393.000000	24952236.000000
+	3.300000	3.300000	1424404.375000	7672437.500000	15855393.000000	24952236.000000
 	4.400000	4.400000	9404830.000000	5665558.500000	7013596.000000	22083984.000000
 	5.500000	5.500000	6655366.000000	8580214.000000	10803569.000000	26039148.000000
 5 rows in set
=== query 49 diff end ===


testing test_371, select substring_index... done; 1/1 subtests FAILED:

=== query 10 diff start ===
--- reference	2024-03-20 16:47:21.256665933 +0700
+++ current	2024-03-20 16:47:21.256585007 +0700
@@ -2,6 +2,6 @@
 	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	0.000000
 	242424.687500
-	36486.984375
+	36486.988281
 3 rows in set

=== query 10 diff end ===
=== query 28 diff start ===
--- reference	2024-03-20 16:47:21.262344928 +0700
+++ current	2024-03-20 16:47:21.262291699 +0700
@@ -2,6 +2,6 @@
 	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	0.000000
 	242424.687500
-	36486.984375
+	36486.988281
 3 rows in set

=== query 28 diff end ===
=== query 45 diff start ===
--- reference	2024-03-20 16:47:21.265824645 +0700
+++ current	2024-03-20 16:47:21.265774374 +0700
@@ -2,6 +2,6 @@
 	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	0.000000
 	242424.687500
-	36486.984375
+	36486.988281
 3 rows in set

=== query 45 diff end ===
=== query 62 diff start ===
--- reference	2024-03-20 16:47:21.269458218 +0700
+++ current	2024-03-20 16:47:21.269393785 +0700
@@ -2,6 +2,6 @@
 	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	0.000000
 	242424.687500
-	36486.984375
+	36486.988281
 3 rows in set

=== query 62 diff end ===
=== query 79 diff start ===
--- reference	2024-03-20 16:47:21.272999119 +0700
+++ current	2024-03-20 16:47:21.272937894 +0700
@@ -2,6 +2,6 @@
 	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	0.000000
 	242424.687500
-	36486.984375
+	36486.988281
 3 rows in set

=== query 79 diff end ===


testing test_445, select upper/lower... done; 1/1 subtests FAILED:

=== query 20 diff start ===
--- reference	2024-03-20 16:49:43.826638941 +0700
+++ current	2024-03-20 16:49:43.826569650 +0700
@@ -2,6 +2,6 @@
 	name	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	ALICE	0.000000
 	BOB	242424.687500
-	CHARLIE	36486.984375
+	CHARLIE	36486.988281
 3 rows in set

=== query 20 diff end ===
=== query 22 diff start ===
--- reference	2024-03-20 16:49:43.831630906 +0700
+++ current	2024-03-20 16:49:43.831576532 +0700
@@ -2,6 +2,6 @@
 	job	geodist(substring_index(j.coord,' ',-1), substring_index(j.coord,' ',1), 0.93, -0.08 )
 	alice	0.000000
 	bob	242424.687500
-	charlie	36486.984375
+	charlie	36486.988281
 3 rows in set

=== query 22 diff end ===

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants